import request from "../../utils/request";
import type {loginForm, loginResData} from "./type"

enum API {
    LOGIN_URL = "/admin/acl/index/login",
    USERINFO_URL = "/admin/acl/index/info",
    LOGOUT_URL = "/admin/acl/index/logout",
}
export const reqLogin = (data: loginForm) => request.post<any, loginResData>(API.LOGIN_URL, data)
export const reqUserInfo = () => request.get(API.USERINFO_URL)
export const reqLoginOut = () => request.post<any, any>(API.LOGOUT_URL)
export const getUsersList = (page:any, limit:any) => request.get<any, any>(`/admin/acl/user/${page}/${limit}`)
export const getRolesList = (page:any, limit:any) => request.get<any, any>(`/admin/acl/role/${page}/${limit}`)
export const addUsers = (data: any) => request.post('/admin/acl/user/save', data)
export const addRoles = (data: any) => request.post('/admin/acl/role/save', data)
export const updateUsersInfo = (data: any) => request.put('/admin/acl/user/update', data)
export const updateRolesInfo = (data: any) => request.put('/admin/acl/role/update', data)
export const getRolesByUsers = (adminId: any) => request.get(`/admin/acl/user/toAssign/${adminId}`)
export const assignRoles = (data: any) => request.post<any, any>('/admin/acl/user/doAssignRole', data)
export const deleteUsers = (id: any) => request.delete<any, any>(`/admin/acl/user/remove/${id}`)
export const deleteRoles = (id: any) => request.delete<any, any>(`/admin/acl/role/remove/${id}`)
export const getMenuListByRole = (roleId: any) => request.get<any, any>(`/admin/acl/permission/toAssign/${roleId}`)
export const setPermissionByRole = (roleId:any, permissionId:any) => request.post<any, any>(`/admin/acl/permission/doAssign?/roleId=${roleId}&permissionId=${permissionId}`)